/* 答题页面样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    padding-bottom: 50px;
}

.container {
    width: 90%;
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 顶部区域 */
.quiz-header {
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 20px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.quiz-header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.quiz-timer {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff3cd;
    padding: 8px 16px;
    border-radius: 25px;
    font-weight: bold;
    color: #856404;
}

.timer-icon {
    font-size: 1.2rem;
}

.timer-text {
    font-size: 1rem;
}

.quiz-title {
    font-size: 1.3rem;
    font-weight: bold;
    color: #333;
    flex: 1;
    text-align: center;
}

.quiz-nav {
    display: flex;
    gap: 10px;
}

.back-btn {
    padding: 8px 16px;
    background: #6c757d;
    color: white;
    text-decoration: none;
    border-radius: 20px;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.back-btn:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

/* 进度条 */
.progress-bar-container {
    height: 8px;
    background: #e9ecef;
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 10px;
}

/* 主要内容区 */
.quiz-container {
    margin-top: 40px;
}

.question-section {
    margin-bottom: 30px;
}

.question-counter {
    text-align: center;
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 20px;
    font-weight: 500;
}

.question-card {
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    margin-bottom: 120px; /* 为固定按钮留出空间 */
}

.question-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #2c3e50;
    line-height: 1.6;
    margin-bottom: 30px;
}

.question-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.option-item {
    padding: 18px 25px;
    border: 2px solid #e9ecef;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f8f9fa;
    position: relative;
    overflow: hidden;
}

.option-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    background: #667eea;
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.option-item:hover {
    border-color: #667eea;
    background: #f0f4ff;
    transform: translateX(5px);
}

.option-item.selected {
    border-color: #667eea;
    background: #e8edff;
}

.option-item.selected::before {
    transform: scaleY(1);
}

.option-item.correct {
    border-color: #28a745;
    background: #d4edda;
}

.option-item.incorrect {
    border-color: #dc3545;
    background: #f8d7da;
}

.option-label {
    font-weight: 600;
    color: #667eea;
    margin-right: 10px;
}

.option-text {
    color: #333;
}

/* 按钮区域 */
.quiz-actions {
    display: none; /* 默认隐藏，开始答题后才显示 */
    justify-content: space-between;
    gap: 20px;
    margin-top: 30px;
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 900;
    background: white;
    padding: 15px 30px;
    border-radius: 50px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-width: 600px;
    width: calc(100% - 60px);
}

.quiz-actions.active {
    display: flex; /* 答题时显示 */
}

.btn-prev, .btn-next, .btn-submit {
    flex: 1;
    padding: 15px 30px;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-prev {
    background: #6c757d;
    color: white;
}

.btn-prev:hover:not(:disabled) {
    background: #5a6268;
    transform: translateY(-2px);
}

.btn-prev:disabled {
    background: #e9ecef;
    color: #adb5bd;
    cursor: not-allowed;
}

.btn-next {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-next:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.btn-submit {
    background: #28a745;
    color: white;
}

.btn-submit:hover {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(40, 167, 69, 0.3);
}

/* 结果弹窗 */
.result-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.result-modal.show {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.result-modal-content {
    background: white;
    border-radius: 20px;
    padding: 40px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.result-header {
    margin-bottom: 30px;
}

.result-icon {
    font-size: 4rem;
    color: #28a745;
    margin-bottom: 15px;
}

.result-header h2 {
    font-size: 2rem;
    color: #2c3e50;
    margin-bottom: 10px;
}

.result-body {
    margin-bottom: 30px;
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.stat-item {
    padding: 20px;
    background: #f8f9fa;
    border-radius: 15px;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 5px;
}

.stat-label {
    color: #666;
    font-size: 0.9rem;
}

.result-message {
    font-size: 1.1rem;
    color: #666;
    line-height: 1.6;
}

.result-actions {
    display: flex;
    gap: 15px;
}

.btn-primary, .btn-secondary {
    flex: 1;
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #f8f9fa;
    color: #333;
    border: 2px solid #e9ecef;
}

.btn-secondary:hover {
    background: #e9ecef;
}

/* ========== AI助手样式 ========== */
/* AI助手浮动按钮 */
.ai-assistant-btn {
    position: fixed;
    right: 30px;
    bottom: 110px; /* 在答题按钮上方 */
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    font-size: 28px;
    cursor: move; /* 可拖动光标 */
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none; /* 防止拖动时选中文本 */
    touch-action: none; /* 防止移动端滚动冲突 */
}

.ai-assistant-btn.dragging {
    transition: none; /* 拖动时禁用过渡效果 */
    opacity: 0.8;
}

.ai-assistant-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(102, 126, 234, 0.6);
}

/* 边界收缩状态 */
.ai-assistant-btn.edge-left {
    transform: translateX(-45px); /* 向左收缩，只露出15px */
}

.ai-assistant-btn.edge-right {
    transform: translateX(45px); /* 向右收缩，只露出15px */
}

.ai-assistant-btn.edge-top {
    transform: translateY(-45px); /* 向上收缩，只露出15px */
}

.ai-assistant-btn.edge-bottom {
    transform: translateY(45px); /* 向下收缩，只露出15px */
}

/* 收缩时显示箭头提示 */
.ai-assistant-btn.edge-left::before {
    content: '→';
    position: absolute;
    font-size: 20px;
    animation: arrowPulse 1.5s ease-in-out infinite;
}

.ai-assistant-btn.edge-right::before {
    content: '←';
    position: absolute;
    font-size: 20px;
    animation: arrowPulse 1.5s ease-in-out infinite;
}

.ai-assistant-btn.edge-top::before {
    content: '↓';
    position: absolute;
    font-size: 20px;
    animation: arrowPulse 1.5s ease-in-out infinite;
}

.ai-assistant-btn.edge-bottom::before {
    content: '↑';
    position: absolute;
    font-size: 20px;
    animation: arrowPulse 1.5s ease-in-out infinite;
}

/* 展开时隐藏箭头 */
.ai-assistant-btn.expanded::before {
    display: none;
}

/* 箭头呼吸动画 */
@keyframes arrowPulse {
    0%, 100% {
        opacity: 0.6;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* 展开状态（悬停或激活时） */
.ai-assistant-btn.edge-left:hover,
.ai-assistant-btn.edge-left.expanded,
.ai-assistant-btn.edge-right:hover,
.ai-assistant-btn.edge-right.expanded,
.ai-assistant-btn.edge-top:hover,
.ai-assistant-btn.edge-top.expanded,
.ai-assistant-btn.edge-bottom:hover,
.ai-assistant-btn.edge-bottom.expanded {
    transform: translate(0, 0) scale(1.05);
}

/* 悬停时箭头变为机器人图标 */
.ai-assistant-btn.edge-left:hover::before,
.ai-assistant-btn.edge-right:hover::before,
.ai-assistant-btn.edge-top:hover::before,
.ai-assistant-btn.edge-bottom:hover::before {
    content: '🤖';
    font-size: 28px;
    animation: none;
    opacity: 1;
}

.ai-assistant-btn:active {
    transform: scale(0.95);
}

/* AI对话框面板 */
.ai-chat-panel {
    position: fixed;
    right: 30px;
    bottom: 100px;
    width: 380px;
    height: 500px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
}

.ai-chat-panel.active {
    display: flex;
    animation: slideInUp 0.3s ease;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* AI对话框头部 */
.ai-chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.ai-chat-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    flex: 1;
}

/* AI服务选择器 */
.ai-service-selector {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s;
    outline: none;
}

.ai-service-selector:hover {
    background: rgba(255, 255, 255, 0.3);
}

.ai-service-selector option {
    background: #667eea;
    color: white;
}

.ai-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ai-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 消息区域 */
.ai-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8f9fa;
}

.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

/* 消息样式 */
.ai-message {
    margin-bottom: 16px;
    display: flex;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-message-user {
    justify-content: flex-end;
}

.ai-message-assistant {
    justify-content: flex-start;
}

.ai-message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
}

.ai-message-user .ai-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-message-assistant .ai-message-content {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 输入区域 */
.ai-chat-input-area {
    padding: 16px;
    background: white;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 10px;
}

.ai-chat-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    transition: border-color 0.2s;
}

.ai-chat-input:focus {
    outline: none;
    border-color: #667eea;
}

.ai-send-btn {
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.ai-send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.ai-send-btn:active {
    transform: translateY(0);
}

.ai-send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* 加载动画 */
.ai-loading {
    display: inline-block;
}

.ai-loading::after {
    content: '...';
    animation: aiLoading 1.5s infinite;
}

@keyframes aiLoading {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .quiz-header-content {
        flex-wrap: wrap;
        gap: 15px;
    }
    
    .quiz-title {
        width: 100%;
        order: -1;
        font-size: 1.1rem;
    }
    
    .question-card {
        padding: 25px;
        margin-bottom: 150px; /* 移动端为固定按钮留更多空间 */
    }
    
    .question-title {
        font-size: 1.2rem;
    }
    
    .quiz-actions {
        flex-direction: row;
        bottom: 80px; /* 移动端调整位置 */
        left: 16px;
        right: 16px;
        transform: none;
        padding: 12px;
        border-radius: 16px;
    }
    
    .btn-prev, .btn-next, .btn-submit {
        width: 100%;
        flex: 1;
    }
    
    .result-stats {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
    
    /* AI助手按钮移动端调整 */
    .ai-assistant-btn {
        right: 20px;
        bottom: 170px; /* 在固定按钮上方 */
    }
}
    
    .stat-value {
        font-size: 2rem;
    }
    
    .result-modal-content {
        padding: 30px 20px;
    }
}

@media (max-width: 480px) {
    .container {
        width: 95%;
        padding: 0 10px;
    }
    
    .quiz-timer {
        padding: 6px 12px;
        font-size: 0.9rem;
    }
    
    .timer-icon {
        font-size: 1rem;
    }
    
    .question-card {
        padding: 20px;
    }
    
    .question-title {
        font-size: 1.1rem;
    }
    
    .option-item {
        padding: 15px 20px;
    }
    
    .result-stats {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    
    .stat-item {
        padding: 15px 10px;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .stat-label {
        font-size: 0.8rem;
    }
    
    .result-icon {
        font-size: 3rem;
    }
    
    .result-header h2 {
        font-size: 1.5rem;
    }
}

/* 题目和选项图片样式 */
.question-image {
    max-width: 100%;
    max-height: 400px;
    width: auto;
    height: auto;
    margin: 15px 0;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: block;
    object-fit: contain;
}

.option-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.option-image {
    max-width: 100%;
    max-height: 200px;
    width: auto;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-top: 8px;
    object-fit: contain;
}

.option-text {
    flex: 1;
}

/* 响应式图片 */
@media (max-width: 768px) {
    .question-image {
        max-height: 300px;
        width: auto;
        height: auto;
    }
    
    .option-image {
        max-height: 150px;
        width: auto;
        height: auto;
    }

    /* AI助手响应式 */
    .ai-assistant-btn {
        right: 20px;
        bottom: 20px;
        width: 50px;
        height: 50px;
        font-size: 24px;
    }

    .ai-chat-panel {
        right: 10px;
        bottom: 80px;
        width: calc(100% - 20px);
        max-width: 380px;
        height: 450px;
    }
}

/* 填空题样式 */
.fill-in-container {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    margin: 20px 0;
    text-align: center;
}

.fill-in-label {
    display: block;
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 20px;
}

.fill-in-input {
    width: 100%;
    max-width: 400px;
    padding: 15px 20px;
    font-size: 16px;
    border: 2px solid #e0e6ed;
    border-radius: 8px;
    outline: none;
    transition: all 0.3s ease;
    background: #f8f9fa;
}

.fill-in-input:focus {
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.fill-in-input:disabled {
    background: #f5f5f5;
    color: #666;
    cursor: not-allowed;
}

.fill-in-input::placeholder {
    color: #999;
    font-style: italic;
}
